﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace odinshrine
{
    class SpriteList
    {
        public int nbre_cases;
        public int[,] tableau;
        int j = 0;
        Vector2 vecteur = new Vector2(0, 0);

        public SpriteList(int nbre)
        {
            nbre_cases = nbre;
            tableau = new int[nbre_cases, 2];
        } 

        public void Init()
        {
            for (int i = 0; i < nbre_cases; i++)
            {
                tableau[i, 0] = -1;
                tableau[i, 1] = -1;
            }
        }

        public void Add(Vector2 coord, int[,] tab)
        {
            if (j >= nbre_cases)
            {
                j = 0;
            }

            tableau[j, 0] = (int)coord.X;
            tableau[j, 1] = (int)coord.Y;
            j++;
        }

        public void Draw(SpriteBatch spriteBatch, Texture2D texture, GraphicsDeviceManager graphics)
        {
            for (int i = 0; i < nbre_cases; i++)
            {
                if (tableau[i, 0] > 0 && tableau[i, 0] < graphics.PreferredBackBufferWidth && tableau[i, 1] < graphics.PreferredBackBufferHeight && tableau[i, 1] > 0)
                {
                    vecteur.X = tableau[i, 0];
                    vecteur.Y = tableau[i, 1];
                    spriteBatch.Draw(texture, vecteur, Color.White);
                }
            }
        }
    }
}
